<?php
$conn = mysql_connect('localhost', 'root', '');
mysql_select_db('adppf', $conn);
//$result = mysql_query("insert into users (id, username) values(20, 'aaa')");
$name = "ab'b";
$st = 'select * from adpv6_2.link where name = ' . "'.". escape($name) ."'";
//$st = 'select * from adpv6_2.link limit 1';
$result = mysql_query($st);
$a = 1;
var_dump($st);
printf($result);

while ($r = mysql_fetch_row($result)) {
	var_dump($r);
	//var_dump(mb_detect_encoding($r[1]));
	//var_dump(mb_convert_encoding($r[1], 'UTF-8'));

}

function escape($s) {
	if(!$s) return '';
	$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s));
	$s = str_replace("'", "\\'", $s);
	return $s;
}

